#include <iostream>
#include<string>
#include<vector>
using namespace std;
bool sort_bylength(vector<string> st) {
    int membercount = st.size();
    int index = 0;
    bool flag = 1;
    for (; index < membercount - 1; ++index) {
        if (st[index].size() <= st[index + 1].size()) {
            flag = 1;
        }
        else
            flag = 0;
        if (!flag)
            return false;
    }
    return true;
}

bool sort_bydir(vector<string> st) {
    int membercount = st.size();
    int index = 0;
    bool flag = 1;
    for (; index < membercount - 1; ++index) {
        if (st[index].compare(st[index + 1]) <= 0) {
            flag = 1;
        }
        else
            flag = 0;
        if (!flag)
            return false;
    }
    return true;
}

int main() {
    int linecount;
    cin >> linecount;
    vector<string> st;
    string tmp;
    while (cin >> tmp) {
        st.push_back(tmp);
    }
    if (sort_bylength(st) && !sort_bydir(st)) {
        printf("lengths");
    }
    else if (!sort_bylength(st) && sort_bydir(st)) {
        printf("lexicographically");
    }
    else if (sort_bylength(st) && sort_bydir(st)) {
        printf("both");
    }
    else {
        printf("none");
    }
}